<template>
  <view class="page">
   <!-- 搜索框使用 -->
   <searchContent ref="searchContent" @search="resetPaginationRefresh"></searchContent>
  </view>
</template>

<script>
import request from "@/utils/request"
import searchContent from "./components/searchContent.vue"

export default {
  computed: {},
  components: { searchContent },
  data() {
    return {
      pagination: {
        current: 1,
        size: 10,
      },
    }
  },
  // 获取活动列表
  onLoad() {
    this.$nextTick(() => {
      this.resetPaginationRefresh()
    })
  },
  onShow() {},
  methods: {
    async getActivityList() {
      const data = await request({
        url: "studyActivity/getActivityPage",
        data: {
          ...this.$refs.searchContent.searchForm,
          ...this.pagination,
        },
        errorHandle: true,
      })
      this.activityList.push(...data.records)
      if (this.activityList.length >= data.total) {
        this.loadMoreStatusText = "noMore"
      } else {
        this.loadMoreStatusText = "more"
      }
    },
    resetPaginationRefresh() {
      this.pagination.current = 1
      this.loadMoreStatusText = "more"
      this.activityList = []
      uni.showLoading({
        title: "加载中",
      })
      this.getActivityList().finally(() => {
        uni.hideLoading()
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.page {
}
</style>
